/* Wrapper class for ship
 * 
 */

package gui.battle;

import java.util.Comparator;

import item.ship.*;

public class BattleShip {

	
	private Ship ship; //the ship being wrapped
	private int baseSpeed; //the base speed of the ship
	private int speed; //the current effective speed of the ship
	private boolean isDead; //holds if the ship is dead
	
	
	//0 param constructor that sets up a basic BattleShip object
	public BattleShip(Ship s){
		
		ship = s;
		baseSpeed = s.speed();
		speed = baseSpeed;
		isDead = false;
	}//default constructor
	
	
	//returns the ship
	public Ship getShip(){
		
		return ship;
	}//getShip
	
	
	//sets the speed to baseSpeed * factor
	public void setSpeed(double factor){
		
		speed = (int)(baseSpeed * factor);
	}//setSpeed
	
	
	//adds given value to speed
	public void addSpeed(int a){
		
		speed += a;
	}//addSpeed
	
	//returns the current speed
	public int getSpeed(){
		
		return speed;
	}//getSpeed
	
	
	//returns a comparator that compares two ship's current speed
	public static Comparator<BattleShip> speedComparator(){
		
		
		return new Comparator<BattleShip>(){
			
			//compares the two ship's speeds
			public int compare(BattleShip t, BattleShip o){
				
				return o.getSpeed() - t.getSpeed();
			}//compare
		};
	}//speedComparator
	
	
	//returns if the passed in panel is equal
	public boolean equals(Object o){
		
		return ((BattleShip)o).getShip().equals(ship);
	}//equals
	
	
} //BattleShip